package _119PascalsTriangleTwo;

import java.util.ArrayList;
import java.util.List;

public class CSolution {

    public static void main(String[] args) {
        System.out.println("aa");
        System.out.println(getNumList(0));
        System.out.println(getNumList(1));
        System.out.println(getNumList(2));
        System.out.println(getNumList(3));
        System.out.println(getNumList(4));
        System.out.println(getNumList(5));
    }

    private static List<Integer> getNumList(int num) {
        List<Integer> result = new ArrayList<>();
        if (num == 0) {
            return result;
        }
        result.add(1);
        for (int i = 0; i < num-1; i++) {
            result = getNextList(result);
        }
        return result;
    }

    private static List<Integer> getNextList(List<Integer> preList) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i <= preList.size(); i++) {
            if (i == 0) {
                list.add(preList.get(0));
            } else if (i == preList.size()) {
                list.add(preList.get(i - 1));
            } else {
                list.add(preList.get(i - 1) + preList.get(i));
            }
        }
        return list;
    }
}

